package com.itheima.work1120;

import java.util.ArrayList;
import java.util.Collections;

public class Demo2 {
    public static void main(String[] args) {
        //定义存储整数的集合
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        list.add(6);
        //打乱顺序
        Collections.shuffle(list);
        System.out.println("乱序后：" + list);
        //升序排序
        Collections.sort(list);
        System.out.println("升序后：" + list);
        //降序排序
        Collections.sort(list, Collections.reverseOrder());
        System.out.println("降序后：" + list);
    }
}
